package top.api.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import top.api.annotation.SystemLog;
import top.api.common.ResponseResult;
import top.api.domain.entity.User;
import top.api.service.BlogLoginService;

@RestController
@Api(tags = "前台登录")
public class BlogLoginController {

    @Autowired
    private BlogLoginService blogLoginService;

    /**
     * 登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    @ApiOperation(value = "login",notes = "只需要userName, password 两个参数")
    @SystemLog("登录操作")
    public ResponseResult login(@RequestBody User user){
        return blogLoginService.login(user);
    }

    /**
     * 退出登录
     * @return
     */
    @PostMapping("/logout")
    @ApiOperation(value = "logout",notes = "必须携带token")
    public ResponseResult logout(){
       return blogLoginService.logout();
    }
}
